package server

const (
	defaultName   = "UnsetServerName"
	defaultListen = "127.0.0.1"
	defaultPort   = 33333
	GRPC          = "grpc"
	HTTP          = "http"
)

type Option struct {
	Name     string
	Listen   string
	Port     int
	Protocol string // tcp or http
}

type SetOption func(*Option) error

func withDefaultName() SetOption {
	return func(rs *Option) error {
		rs.Name = defaultName
		return nil
	}
}

func withDefaultPort() SetOption {
	return func(rs *Option) error {
		rs.Port = defaultPort
		return nil
	}
}

func withDefaultListen() SetOption {
	return func(rs *Option) error {
		rs.Listen = defaultListen
		return nil
	}
}

func defaultOptions() []SetOption {
	return []SetOption{
		withDefaultName(),
		withDefaultListen(),
		withDefaultPort(),
	}
}
